var def_lat = 49.44;
var def_lng = 32.06;
var def_zoom = 13;
var panOffset = 100;

var map;
var marker;

function getParameter(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return null;
  else
    return results[1];
}

function fillTheUrl(params, urlname) {
   var a_elem = document.getElementById(urlname);
   if (a_elem.href.indexOf('?') > 0) {
      a_elem.href = a_elem.href.substring(0, a_elem.href.indexOf('?'))
   }
   a_elem.href = a_elem.href + '?' + params;
}

function setLinkUrl() {
   var a_elem = location.href;
   if (a_elem.indexOf('google-maps-mobile') > 0) {
      document.getElementById('textlink').value = document.getElementById('google-maps-mobile').href;
   } else if (a_elem.indexOf('google-maps') > 0) {
      document.getElementById('textlink').value = document.getElementById('google-maps').href;
   } else if (a_elem.indexOf('yandex-maps') > 0) {
      document.getElementById('textlink').value = document.getElementById('yandex-maps').href;
   } else if (a_elem.indexOf('visicom-maps') > 0) {
      document.getElementById('textlink').value = document.getElementById('visicom-maps').href;
   } else {
      // default
      alert('There is no Map Service in the page location.');
   }
}

function markerButtons() {
   if (document.getElementById("setmarker").style.display == "none") {
      document.getElementById("setmarker").style.display = "block";
      document.getElementById("removemarker").style.display = "none";
   } else {
      document.getElementById("setmarker").style.display = "none";
      document.getElementById("removemarker").style.display = "block";
   }
}

function initStyleButtons() {
   styleButtons();
}

function styleButtons() {
   if (document.getElementById("newstyle").style.display != "none") {
      // get new style
      document.getElementById("newstyle").style.display = "none";
      document.getElementById("oldstyle").style.display = "block";
      document.getElementById("map_links").style.display = "block";
      document.getElementById("map_links_old").style.display = "none";
   } else {
      // get old style
      document.getElementById("newstyle").style.display = "block";
      document.getElementById("oldstyle").style.display = "none";
      document.getElementById("map_links").style.display = "none";
      document.getElementById("map_links_old").style.display = "block";
   }
}

function initMarkerButtons(visibleMarker) {
   if (visibleMarker) {
      document.getElementById("setmarker").style.display = "none";
      document.getElementById("removemarker").style.display = "block";
   } else {
      document.getElementById("setmarker").style.display = "block";
      document.getElementById("removemarker").style.display = "none";
   }
}